{{!--

 Copyright 2016 LinkedIn Corp.

 Licensed under the Apache License, Version 2.0 (the "License"); you may not
 use this file except in compliance with the License. You may obtain a copy of
 the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 License for the specific language governing permissions and limitations under
 the License.

--}}

<div class="nav-extension"></div>

<div class="container" role="main">
  <div class="shadow box search-box">
    <h4>Exceptions</h4>
    <hr class="horizontal-line">
    <br/>

    <form id="search-form" {{action 'search' on="submit"}}>
      <label>Workflow execution url/id</label>

      {{input type="text" class="form-control" id="form-workflow-id" name="workflow" placeholder="workflow execution url" value=workflowIdValue}}
      {{# if showSchedulerDropdown}}
        <select class="form-control" id="form-job-type" name="job-type"
                onChange={{action 'selectScheduler' value="target.value"}}>
          {{#each model.exceptionStatus.schedulers as |scheduler|}}
            <option value={{scheduler.name}}>{{scheduler.name}}</option>
          {{/each}}
        </select>
      {{/if}}
      <br/>
      <button class="btn wf-button" id="submit-button" action="search">Search</button>
      <br/>
      <br/>
    </form>
  </div>





  {{#if loading}}
    {{loading-panel message="searching..."}}
  {{else}}
    {{#if showExceptions}}
      {{#unless (eq model null)}}
        <div class="shadow summary-list-container">
          <div class="summary-list-header"><a href={{workflowId}}>Workflow</a></div>
          <hr class="horizontal-line">
          {{#each model.exceptions as |job|}}

            {{#cp-panels class='u-margin-bottom workflow-panel-cp' accordion=true as |panels|}}
              {{#panels.panel as |p|}}
                {{#if (eq job.type "MR")}}
                  {{map-reduce-exception job=job}}
                {{else if (eq job.type "SCRIPT")}}
                  {{#p.toggle}}
                    <p>{{job.name}}</p>
                  {{/p.toggle}}

                  {{#p.body}}
                    <div class="box">
                      <pre>{{job.exceptionSummary}}</pre>
                    </div>
                  {{/p.body}}

                {{else if (eq job.type "SCHEDULER")}}
                  {{#p.toggle}}
                    <p>{{job.name}}</p>
                  {{/p.toggle}}

                  {{#p.body}}
                    <div class="box">
                      <pre>{{job.exceptionSummary}}</pre>
                    </div>
                  {{/p.body}}
                {{/if}}
              {{/panels.panel}}
            {{/cp-panels}}

          {{/each}}
          <br/>
        </div>
      {{/unless}}
    {{/if}}
  {{/if}}

</div>




